package acwing;

import java.io.*;

public class acwing9 {
    static int N= 110;
    static int M=110;
    static int n;//物品组数
    static int m;//背包容量
    static int[][] v=new int[N][N];
    static int[][] w=new int[N][N];
    static int[] s=new int[N];//分组
    static int[] dp=new int[N];
    static BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter log=new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] t = read.readLine().split(" ");
        n=Integer.parseInt(t[0]);
        m=Integer.parseInt(t[1]);
        for(int i=1;i<=n;i++){
            String s1 = read.readLine();
            s[i] = Integer.parseInt(s1);
            for(int j=0;j<s[i];j++){
                String[] s2 = read.readLine().split(" ");
                v[i][j]=Integer.parseInt(s2[0]);
                w[i][j]=Integer.parseInt(s2[1]);
            }
        }

        for(int i=1;i<=n;i++){//枚举组别
            for(int j=m;j>=0;j--)
            {
                //枚举背包容量
                for(int k=0;k<s[i];k++)//枚举选择第i个物品
                    if(j>=v[i][k])dp[j]=Math.max(dp[j],dp[j-v[i][k]]+w[i][k]);
            }
        }
        log.write(Integer.toString(dp[m]));
        log.flush();
    }

}
